package objects 
{
	import objects.Effect;
	import starling.display.Sprite;
	/**
	 * ...
	 * @author Vượng
	 */
	public class ManagerEffect 
	{
		public var m_layer :Sprite;
		private static var _instance:ManagerEffect;
		private var _ListEff:Array;
		public function ManagerEffect() 
		{
			_ListEff = new Array();
		}
		
		static public function get instance():ManagerEffect 
		{
			if (_instance == null)
			{
				_instance = new ManagerEffect();
			}
			return _instance;
		}
		
		public function get ListEff():Array 
		{
			return _ListEff;
		}
		
		public function set ListEff(value:Array):void 
		{
			_ListEff = value;
		}
		public function AddEff( _Eff:Effect):void
		{
			ListEff.push(_Eff);
		}
		public function RemoveEff( _Index:int):void
		{
			m_layer.removeChild(ListEff[_Index]);
			ListEff.splice(_Index, 1);
		}
		public function update(dt:Number):void
		{
			for (var i:int = 0; i < ListEff.length; i++)
			{
				ListEff[i].update(dt);
				if (ListEff[i].m_coolDown <= 0)
				{
					RemoveEff(i);
				}
				
			}
		}
		
		public function CollisionWithArray ( _enemy : Array, dt : Number) :void
		{
			for (var i:int = 0; i < ListEff.length; i++)
			{
				ListEff[i].CollisionWithArray(_enemy,dt);
				
			}
		}
		
	}

}